<?php
namespace app\subscribe;

use app\mini\service\Weapp;
// Download：https://github.com/aliyun/openapi-sdk-php
// Usage：https://github.com/aliyun/openapi-sdk-php/blob/master/README.md

class Notice 
{
    static $tmpIds = [
        'entry' => '01xG-md3iDU-1CkVTophAKunynLRoFt1lVK2pr9-jio', // 报名成功通知
    ];

    public $message = '';
    public $state = 200;
    private $handle;

    public function __construct()
    {
        $this->handle = new Weapp;
    }
    /*
     * 模板消息(统一服务消息,通过公众号发送)
     */
    private function send(string $openid, string $tmpl_id, string $path, array $data = []){
        $this->handle->send($openid, $tmpl_id, $path, $data);
    }
    /*
     * 学员报名
     */
    public function entry($params = []){
        return $this->send($params['openid'], self::$tmpIds['entry'], 'sub-user/pages/detail/detail?id=' . $params['plan_id'], [
            'thing5' => $params['name'], // 姓名
            'phone_number8' => $params['mobile'], // 联系方式
            'thing1' => $params['activity_title'], // 活动名称
            'time7' => $params['time'],// 活动时间
        ]);
    }
}
